package com.daydayup.learn;


/***
 * 快慢相等值不变,慢针不动快针走
 * 快慢不等值情况1，慢针向前一步走,快针赋值给慢针,快针向前一步走
 */
public class LeetCode026 {

    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(nums));
    }

    public static int removeDuplicates(int[] nums) {
        int slow = 0,fast = 0;
        while (fast < nums.length){
            if (nums[slow] != nums[fast]){
                slow++;
                nums[slow] = nums[fast];
            }
            fast++;
        }
        return slow + 1;
    }
}
